package tx.oopa.circuit.view;

import java.util.ArrayList;
import java.util.List;

import tx.oopa.circuit.node.AbstractNode;

public final class NodeComponentFactory {

    /**
     * Creates a NodeComponent for the given AbstractNode.
     * 
     * @param node
     * @return
     */
    public static final NodeComponent createNodeComponent(AbstractNode node) {
        if(node == null) {
            throw new IllegalArgumentException("Node cannot be null.");
        }
        return new NodeComponent(node);
    }

    /**
     * Creates a list of NodeComponent instances for the given AbstractNode
     * collection.
     * 
     * @param nodes
     * @return
     */
    public static final List<NodeComponent> createNodeComponents(
            List<AbstractNode> nodes) {
        if(nodes == null) {
            throw new IllegalArgumentException("Nodes cannot be null.");
        }

        List<NodeComponent> nodeComponents = new ArrayList<NodeComponent>(
                nodes.size());
        for(AbstractNode node : nodes) {
            nodeComponents.add(createNodeComponent(node));
        }

        return nodeComponents;
    }

}
